package com.atguigu.gmall.cart.config;

import com.atguigu.gmall.common.utils.RsaUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;
import java.security.PublicKey;

@ConfigurationProperties(prefix = "jwt")
@Data
@Slf4j
public class JwtProperties {
     private String pubKeyPath;
     private String cookieName;
     private Integer expire;
     private String userKey;

     private PublicKey publicKey;

     @PostConstruct
    public void init(){
         try {
             //通过公钥文件获取公钥对象
             publicKey = RsaUtils.getPublicKey(pubKeyPath);
         } catch (Exception e) {
             e.printStackTrace();
             log.error("获取公钥对象失败!");
         }
     }
}
